<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/init.jsp"%>
<script type="text/javascript">
	$(function() {
		$("#form1").validate({
			rules : {
				'name' : {
					required : true,
					maxlength : 50
				},
				'code' : {
					required : true,
					maxlength : 10,
					minlength : 10,
					remote : {
						type : "POST",
						url : "${path}/ix/bank/unique_code.htm"
					}
				},
				'super_id' : {
					required : true
				},
				'city_code' : {
					required : true
				},
				'area_name' : {
					required : true
				}
			},
			messages : {
				code : {
					remote : "该编码已存在，请重新输入！"
				}
			}
		});
	});
	function mysubmit() {
		$("#form1").submit();
	}
	var listlayer;
	function getArea() {
		listlayer = $.layer({
			type : 2,
			shadeClose : false,
			title : false,
			closeBtn : [ 1, true ],
			shade : [ 0.6, '#000' ],
			border : [ 0 ],
			offset : [ '20px', '' ],
			area : [ '320px', ($(window).height() - 50) + 'px' ],
			iframe : {
				src : '${path}/ix/bank/get_location.htm'
			}
		});
	}
	function saveArea(id, name, code, city_name) {
		$("input[name='area_name']").val(name + "(" + code + ")");
		$("input[name='area_id']").val(id);
		$("input[name='city_code']").val(
				city_name + "(" + code.substring(0, 2) + ")");
		layer.closeAll();
	}
</script>

<!-- 内容 -->
<div>
	<form method="post" action="${path}/ix/bank/add.htm" id="form1">
		<input name='super_id' value='${bank._id }' type="hidden" />
		<h2>
			<div>添加[${bank.name}]下属机构</div>
		</h2>
		<table width="99.6%" class="lindex">
			<tr>
				<th align="right">机构编码：</th>
				<td align="left"><input name="code" type="text" maxlength="10" />
				</td>
				<th align="right">机构名称：</th>
				<td align="left"><input name="name" type="text" maxlength="60" />
				</td>
			</tr>
			<tr>
				<th align="right">上级机构：</th>
				<td align="left">${bank.name }</td>
				<th align="right">省市代码：</th>
				<td align="left"><input name="city_code" readonly="readonly"
					value="" type="text" maxlength="100" onclick="getArea()" /> <a
					href="javascript:getArea()"><img alt="请选择所属的区域"
						src="${path }/style_cp/img/02.gif" /></a></td>
			</tr>
			<tr>
				<th align="right">机构级别：</th>
				<td align="left"><input name="level_id" type="hidden"
					value="${bankLevel._id }"> ${bankLevel.name}</td>
				<th align="right">所属区域：</th>
				<td align="left"><input name="area_id" type="hidden"
					maxlength="100" /> <input name="area_name" readonly="readonly"
					type="text" maxlength="100" onclick="getArea()" /> <a
					href="javascript:getArea()"><img alt="请选择所属的区域"
						src="${path }/style_cp/img/02.gif" /></a></td>
			</tr>
			<tr>
				<th align="right">机构类型：</th>
				<td align="left"><input name="type" value="营业机构" type="radio"
					checked="checked">营业机构 <input name="type" value="管理机构"
					type="radio">管理机构</td>
				<th align="right">机构状态：</th>
				<td align="left">启用</td>
			</tr>
			<tr>
				<th align="right">备注：</th>
				<td align="left" colspan="3"><textarea name="note" rows="5"
						cols="50" maxlength="255"></textarea></td>
			</tr>
			<tr>
				<th colspan="4"><a href="javascript:mysubmit();" class="asave">
						【保存】 </a>
				</th>
			</tr>
		</table>
	</form>
</div>
